package com.example.ai.etl.reader;

import org.springframework.ai.document.Document;
import org.springframework.ai.reader.JsonMetadataGenerator;
import org.springframework.ai.reader.JsonReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class MyJsonReader {

    public List<Document> get(String classFilepath,JsonMetadataGenerator jsonMetadataGenerator,String... jsonKeysToUse){
        JsonReader jsonReader = new JsonReader(new ClassPathResource(classFilepath),
                jsonMetadataGenerator,jsonKeysToUse);
        List<Document> documents = jsonReader.get();
        return documents;
    }
}
